package com.zkthink.ceres.product.controller;

import com.zkthink.ceres.product.entity.ResourcePit;
import com.zkthink.ceres.product.dto.ResourcePitSaveDTO;
import com.zkthink.ceres.product.dto.ResourcePitUpdateDTO;
import com.zkthink.ceres.product.dto.ResourcePitPageDTO;
import com.zkthink.ceres.product.service.ResourcePitService;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.zkthink.base.controller.SuperController;
import com.zkthink.base.R;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import com.zkthink.security.annotation.PreAuth;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 前端控制器
 * 蛋坑表
 * </p>
 *
 * @author JustArgo
 * @date 2020-09-11
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/resourcePit")
@Api(value = "ResourcePit", tags = "蛋坑表")
@PreAuth(replace = "resourcePit:")
public class ResourcePitController extends SuperController<ResourcePitService, Long, ResourcePit, ResourcePitPageDTO, ResourcePitSaveDTO, ResourcePitUpdateDTO> {

    /**
     * Excel导入后的操作
     *
     * @param list
     */
    @Override
    public R<Boolean> handlerImport(List<Map<String, String>> list){
        List<ResourcePit> resourcePitList = list.stream().map((map) -> {
            ResourcePit resourcePit = ResourcePit.builder().build();
            //TODO 请在这里完成转换
            return resourcePit;
        }).collect(Collectors.toList());

        return R.success(baseService.saveBatch(resourcePitList));
    }
}
